package RadianceM.DistributionSystem;

import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;

import java.net.InetAddress;
import java.net.UnknownHostException;

@SpringBootApplication
@ServletComponentScan
@Slf4j
@MapperScan(basePackages = {"RadianceM.DistributionSystem.mapper"})
public class DSApplication {
	public static void main(String[] args) throws UnknownHostException {
		ConfigurableApplicationContext application = SpringApplication.run(DSApplication.class, args);
		info(application);
	}

	static void info(ConfigurableApplicationContext application) throws UnknownHostException {
		Environment env = application.getEnvironment();
		String ip = InetAddress.getLocalHost().getHostAddress();
		String port = env.getProperty("server.port");
		String active = env.getProperty("spring.profiles.active");
		String contextPath = env.getProperty("server.servlet.context-path")!=null?env.getProperty("server.servlet.context-path"):"";
		String knife4jPath = env.getProperty("knife4j.path");
		String giteeUrl = env.getProperty("local.gitee.url");
		String dmUrl = env.getProperty("local.dm.url");

		log.info("\n" +
				"\n" +
				"____                 __\n" +
				"/ \\ _`\\             \\ \\ \\  __                                  /'\\_/`\\\t\t\t\t\t"+"欢迎启动:【光辉之岩-数字化公寓选调系统】(RadianceM-DistributionSystem)"+"\n" +
				"\\ \\ \\L\\ \\     __     \\_\\ \\/\\_\\     __      ___     ___     __ /   \\   \\\t\t\t\t\t" + "当前系统程序环境:【 " + active + " 】\n" +
				" \\ \\ ,  /   /'__`\\   /'_` \\ \\ \\  /'__`\\  /' _ `\\  /'___\\ /'__`\\ \\ \\__\\ \\\t\t\t\t\t" + "项目Gitee地址: \t" + giteeUrl + "\n" +
				"  \\ \\ \\\\ \\ / /\\L\\.\\_/\\ \\L\\ \\ \\ \\/ / \\L\\.\\_/ / \\/ / /   \\__//\\__\\ \\ \\__\\ \\\t\t\t\t\t" + "本地项目地址: \thttp://localhost:" + port + contextPath + "\n" +
				"  \\ \\_\\ \\_\\ \\__/.\\_\\ \\___,_\\ \\_\\ \\__/.\\_\\ \\_\\ \\_\\ \\____\\ \\____\\\\ \\_\\\\ \\_\\\t\t\t\t\t" + "项目内网地址: \thttp://" + ip + ':' + port + contextPath + "\n" +
				"    \\/_/\\/ /\\/__/\\/_/\\/__,_ /\\/_/\\/__/\\/_/\\/_/\\/_/\\/____/\\/____/ \\/_/ \\/_/\t\t\t\t\t" + "项目线上地址: \t" + dmUrl + contextPath + "\n" +
				":: RadianceM ::                                                   (v1.0.0)\t\t\t\t\t" + "Api接口文档: \t\thttp://" + ip + ":" + port + contextPath + knife4jPath + "\n" +
				"\n" +
				"");
	}
}


